import cv2

# 读取图像
image = cv2.imread('./data/train/image/0.png')

# 沿水平轴翻转
flipped_horizontal = cv2.flip(image, 1)

# 沿垂直轴翻转
flipped_vertical = cv2.flip(image, 0)

# 同时沿水平和垂直轴翻转
flipped_both = cv2.flip(image, -1)

# 显示结果
cv2.imshow('Original', image)
cv2.imshow('Flipped  Horizontal', flipped_horizontal)
cv2.imshow('Flipped  Vertical', flipped_vertical)
cv2.imshow('Flipped  Both', flipped_both)

cv2.waitKey(0)
cv2.destroyAllWindows()

###############################################
# 读取图像
image = cv2.imread('./data/train/image/0.png')

# 将 BGR 图像转换为灰度图像
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# 将 BGR 图像转换为 HSV 颜色空间
hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)

# 将 BGR 图像转换为 RGB 颜色空间
rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# 显示结果
cv2.imshow('Original', image)
cv2.imshow('Gray', gray_image)
cv2.imshow('HSV', hsv_image)
cv2.imshow('RGB', rgb_image)

cv2.waitKey(0)
cv2.destroyAllWindows()

import numpy as np

# 假设有一个 3x3 的单通道图像
image = np.array([[1, 2, 3],
                  [4, 5, 6],
                  [7, 8, 9]])

# 调整形状为 (1, 3, 3)
reshaped_image = image.reshape(1, image.shape[0], image.shape[1])

print("Original Shape:", image.shape)
print("Reshaped Shape:", reshaped_image.shape)
print("Reshaped Image:\n", reshaped_image)